package com.hup.minicontroller.common.constant;

import androidx.core.util.Consumer;

import com.hup.minicontroller.common.hardware.ActionMocker;

/**
 * 控制功能的constant
 *
 * @author hugan
 * @date 2021/5/6
 */
public abstract class ControlActionConstant {

    /**
     * 按钮
     */
    public enum FunctionButton {
        BACK(1, "返回", false, ActionMocker::buttonBack),
        HOME(2, "主页", true, ActionMocker::buttonHome),
        APP(3, "app", true, ActionMocker::buttonApp);

        public final int index;
        public final String desc;
        public boolean runOnUiThread;
        public final Consumer<ActionMocker> action;

        FunctionButton(int index, String desc, boolean runOnUiThread, Consumer<ActionMocker> action) {
            this.index = index;
            this.desc = desc;
            this.runOnUiThread = runOnUiThread;
            this.action = action;
        }

        public static FunctionButton get(int button) {
            for (FunctionButton value : values()) {
                if (value.index == button) return value;
            }
            return null;
        }

        @Override
        public String toString() {
            return "FunctionButton{" +
                    "desc='" + desc + '\'' +
                    '}';
        }
    }

}
